
package voxelTest;

import java.util.Scanner;

public class Interpreter extends Thread {
	
	public void run() {
		Scanner scanner = new Scanner(System.in);
		boolean salir = false;
		while(!salir) {
			try {
				String[] line = scanner.nextLine().toUpperCase().split(" ");
				switch(line[0]) {
				case "PAUSE": GC.PAUSE = true; break;
				case "RESUME": GC.PAUSE = false; GC.STEP = 0; break;
				case "RESTART": GC.RESTART = true; break;
				case "STEP":  {
					if (!GC.PAUSE) {
						System.err.println("Can't step without pausing");
						break;
					}
					if (Integer.parseInt(line[1]) <= 0) {
						System.err.println("Can't step negative or zero");
						break;
					}
					GC.STEP = Integer.parseInt(line[1]); 
					break;}
				case "SET": {
					switch (line[1]) {
					case "SPEED": GC.MAZE_SLOWNESS = Integer.parseInt(line[2]); System.out.println("Speed set to: " + GC.MAZE_SLOWNESS); break;
					case "PROB": GC.PRIM_PROB = Double.parseDouble(line[2]); System.out.println("Probability set to: " + GC.PRIM_PROB); break;
					case "WIDTH": GC.MAZE_WIDTH = Integer.parseInt(line[2]); System.out.println("Width set to: " + GC.MAZE_WIDTH); break;
					case "HEIGHT": GC.MAZE_HEIGHT = Integer.parseInt(line[2]); System.out.println("Height set to: " + GC.MAZE_HEIGHT); break;
					case "STATUS": GC.PRINT_STATUS = Boolean.parseBoolean(line[2]); System.out.println("Status set to: " + GC.PRINT_STATUS); break;
					}
					break;
				}
				case "EXIT": salir = true; break;
				default: System.out.println("Unknown command"); 
				}
			} catch (Exception ex) {
				System.err.println("Error en la lectura");
			}
		}
		scanner.close();
	}
	
	
}